<?php
//订阅端 常驻进程
include './RedisDriver.php';
ini_set('default_socket_timeout', -1); //不超时
$redis = new \RedisDriver();
$result = $redis->subscribe(array('subscribe'), 'callback');

function callback($instance, $channelName, $message) {
    //不能使用除广播外的其他命令（4条命令）
    $url = "http://pay.qianf8.cn/home/Work/sendNotify";
    request_post($url);
}

/* author@zhou
 * 功能：发送数据
 * return 
 */
function request_post($url ='',$param ='') {
    $postUrl = $url;
    $curlPost = $param;
    $ch = curl_init();//初始化curl
    curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定网页
    curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
    curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
    curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8','Content-Length: ' . strlen($curlPost)));
    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
    curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);

    $data = curl_exec($ch);//运行curl
    // var_dump(curl_errno($ch));die;
    curl_close($ch);
    return $data;
}